# -*-coding: utf-8 -*-
#锟斤拷锟斤拷舜锟斤拷锟�
from twisted.internet import reactor, protocol
from NetMsgLib import UniversaService

dict = {
"error" : 
'''HYCP/1.0 401 ddd\r
From:NMA\r
To:TAU\r
\r
''',
#保活
"/KeepLive" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
Expirse:60\r
\r
''',

"/GetInitData?SoftType=TConfS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="TConfS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080" HYCPPort="3079"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="127.0.0.1" HTTPPort="3080"/>
</Domain>
</InitData>''' ,

"/GetInitData?SoftType=NConfS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="NConfS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=ELogS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="ELogS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=NLogS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="NLogS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=TLogS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="TLogS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=PSS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="PSS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=EventS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="EventS_001@mobile" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort="3082"/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.24" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.24" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="192.168.26.34" HTTPPort="3091"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=MSS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="MSS_001@hyc" name="ABC" IP="172.17.1.44" HTTPPort="3081" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.24" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=TMS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="TMS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort=""/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=LDS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="LDS_001@hyc" name="ABC" IP="172.17.1.43" HTTPPort="3080" HYCPPort="3081"/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.43" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.43" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.43" HTTPPort="3081"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=MDS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="MDS_001@picc" name="ABC" IP="172.17.1.44" SIPPort="3006" RTSPPort="-1" HYCPPort="3014"/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=MDU" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="MDU_001@picc" name="ABC" IP="172.17.1.44"/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=PresS" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="PresS_001@picc" name="ABC" IP="172.17.1.44" HTTPPort="3080" HYCPPort="3082"/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
"/GetInitData?SoftType=TAU" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="TAS_001@picc" name="" IP="172.17.1.34" HTTPPort="3011" SIPPort="3012" RTSPPort="-1" HYCPPort="-1"/>
<Domain ID="hyc" Name="江苏省">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
</Domain>
</InitData>''',
#TAG
"/GetInitData?SoftType=TAG" :
'''HYCP/1.0 200 OK\r
User-Agent: NMA/virtual by python v1.0\r
\r
<InitData>
<Service Account="TAG_001@wan.changzhou" name="ABC" IP="172.17.1.44" HTTPPort="" HYCPPort=""/>
<Domain ID="wan.changzhou" Name="wan.changzhou">
<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3080"/>
<NLogS ID="LogS_001" Name="" IP="172.17.1.44" HTTPPort="3080" />
<NConfS ID="ConfS_001" name="" IP="172.17.1.44" HTTPPort="3080"/>
<Domain ID="wan.changzhou"/>
</Domain>
</InitData>''',

#模拟一个假的接口
"/piccInterface?Type=JSON" :
'''HTTP/1.0 200 OK
Content-Type: text/html;charset=utf-8

{
  "brandName":"东风雪铁龙DC7168A",
  "claimTimes":3,
  "damageAddress":"徐州市云龙区绿地世纪城",
  "damageTime":{"date":8,"day":3,"hours":23,"minutes":50,"month":4,"seconds":55,"time":1368028255000,"timezoneOffset":-480,"year":113},
  "insuedDate":"2012-11-01 - 2013-11-01",
  "insuredName":"王勇",
  "licenseNo":"苏CA097V",
  "registNo":"RDAT201332030000021054",
  "remark":"本车行驶时撞苏CNV750大众，本车前部受损，三者车前部受损，提醒报警，告知相关事宜，待来电。",
  "reportTime":{"date":9,"day":4,"hours":0,"minutes":4,"month":4,"seconds":55,"time":1368029095000,"timezoneOffset":-480,"year":113},
  "reportorName":"王勇",
  "reportorNumber":"15852151948",
  "send4sName":"徐州润龙",
  "specDriver":false
}''' ,

#AssessService的配置信息
"/GetInitData?SoftType=AssessService" :
'''HYCP/1.0 200 OK
User-Agent: NMA/virtual by python v1.0

<InitData>
	<Service Account="AssessService_002@picc" name="" IP="172.17.1.77" SIPPort="3006"  HTTPPort="3080" />
	<Domain ID="wuzhong.suzhou.jiangsu" Name="">
		<NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3002" />
		<NLogS ID="NLogS_001" Name="" IP="172.17.1.44" HTTPPort="3003" />
		<NConfS ID="NConfS_001" name="" IP="172.17.1.44" HTTPPort="3080" />
		<TMS ID="TMS_001" name="" IP="172.17.1.44" HTTPPort="3080" />
	</Domain>
</InitData>''',
#AS的配置信息
"/GetInitData?SoftType=AS" :
'''HYCP/1.0 200 OK
User-Agent: NMA/virtual by python v1.0

<InitData>
    <Service Account="AS_001@picc" name="" IP="172.17.1.77" SIPPort="3006"  HTTPPort="3080" />
    <Domain ID="wuzhong.suzhou.jiangsu" Name="">
        <NMS ID="NMS_001" Name="" IP="172.17.1.44" HTTPPort="3002" />
        <NLogS ID="NLogS_001" Name="" IP="172.17.1.44" HTTPPort="3003" />
        <NConfS ID="NConfS_001" name="" IP="172.17.1.44" HTTPPort="3080" />
        <TMS ID="TMS_001" name="" IP="172.17.1.44" HTTPPort="3080" />
    </Domain>
</InitData>''',
#ASM的配置信息
"/GetInitData?SoftType=ASM" :
'''HYCP/1.1 200 OK
User-Agent: NMA/virtual by python v1.0

<InitData>
    <Service Account="ASManager_001@picc" name="" IP="172.17.1.44" SIPPort="3006"  HTTPPort="3005" />
    <Domain ID="wuzhong.suzhou.jiangsu" Name="">
        <NLogS ID="NLogS_001" Name="" IP="127.0.0.1" HTTPPort="3003" />
        <NConfS ID="NConfS_001" name="" IP="172.17.1.44" HTTPPort="3080" />
        <TMS ID="TMS_001" name="" IP="172.17.1.44" HTTPPort="3080" />
    </Domain>
</InitData>'''
}
	
class NMAFactory(protocol.Factory):
	protocol=UniversaService;
	dict = dict
class NMA:
	def __init__(self, port):
		print "NMA started at port %d"%port
		reactor.listenTCP(port,NMAFactory())

nma = NMA(3000)
reactor.run()
